package org.linlinjava.litemall.admin.web2.goods.req;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.linlinjava.litemall.db.domain.TGoods;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 保存拼团和秒杀请求dto
 */
@ApiModel
public class GReq6 {

    @ApiModelProperty("商品id")
    private Integer id;

    @ApiModelProperty("图片")
    private String img;

    @ApiModelProperty("短标题")
    private String name;

    @ApiModelProperty("成本价")
    private Double costPrice;

    @ApiModelProperty("市场价")
    private Double salePrice;

    @ApiModelProperty("秒杀价、拼团价")
    private Double currentPrice;

    @ApiModelProperty("佣金比例")
    private Integer commission;

    @ApiModelProperty("几人团")
    private Integer groupNumber;

    @ApiModelProperty("活动库存")
    private Integer activityStock;

    @ApiModelProperty("初始销量")
    private Integer initSaleCount;

    @ApiModelProperty("限购数目")
    private Integer personLimit;

    @ApiModelProperty("新人专享")
    private Boolean newPerson;

    @ApiModelProperty("活动开始时间[YYYY-MM-dd HH:mm:ss]")
    private String activityBegin;

    @ApiModelProperty("活动结束时间[YYYY-MM-dd HH:mm:ss]")
    private String activityEnd;


    public TGoods setGoods(TGoods goods) {
        goods.setMainPic(img);
        goods.setMainTitle(name);
        goods.setCostPrice(new BigDecimal(costPrice));
        goods.setSalePrice(new BigDecimal(salePrice));
        goods.setCurrentPrice(new BigDecimal(currentPrice));
        if (commission != null)
            goods.setCommission(commission);
        if (groupNumber != null)
            goods.setGroupNumber(groupNumber);
        goods.setDailyLimit(activityStock);
        goods.setPersonLimit(personLimit);
        goods.setIsNew(newPerson);

        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        goods.setActivityBegin(LocalDateTime.parse(activityBegin, format));
        goods.setActivityEnd(LocalDateTime.parse(activityEnd, format));

        return goods;
    }



    public String getImg() {
        return img;
    }

    public void setImg(String img) {
        this.img = img;
    }


    public Integer getGroupNumber() {
        return groupNumber;
    }

    public void setGroupNumber(Integer groupNumber) {
        this.groupNumber = groupNumber;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getCostPrice() {
        return costPrice;
    }

    public void setCostPrice(Double costPrice) {
        this.costPrice = costPrice;
    }

    public Double getSalePrice() {
        return salePrice;
    }

    public void setSalePrice(Double salePrice) {
        this.salePrice = salePrice;
    }


    public Double getCurrentPrice() {
        return currentPrice;
    }

    public void setCurrentPrice(Double currentPrice) {
        this.currentPrice = currentPrice;
    }

    public Integer getCommission() {
        return commission;
    }

    public void setCommission(Integer commission) {
        this.commission = commission;
    }

    public Integer getActivityStock() {
        return activityStock;
    }

    public void setActivityStock(Integer activityStock) {
        this.activityStock = activityStock;
    }

    public Integer getInitSaleCount() {
        return initSaleCount;
    }

    public void setInitSaleCount(Integer initSaleCount) {
        this.initSaleCount = initSaleCount;
    }

    public Integer getPersonLimit() {
        return personLimit;
    }

    public void setPersonLimit(Integer personLimit) {
        this.personLimit = personLimit;
    }

    public Boolean getNewPerson() {
        return newPerson;
    }

    public void setNewPerson(Boolean newPerson) {
        this.newPerson = newPerson;
    }

    public String getActivityBegin() {
        return activityBegin;
    }

    public void setActivityBegin(String activityBegin) {
        this.activityBegin = activityBegin;
    }

    public String getActivityEnd() {
        return activityEnd;
    }

    public void setActivityEnd(String activityEnd) {
        this.activityEnd = activityEnd;
    }
}
